#ifndef __MY_UTILS_H__
#define __MY_UTILS_H__

#include "defines.h"

#include <thread>
#include <chrono>

using myclock = std::chrono::steady_clock;
using mytime_point = std::chrono::time_point<myclock>;

class Utils {
private:
	using ms_t = std::chrono::milliseconds;

public:
	static void sleep(int ms) {
		std::this_thread::sleep_for(ms_t(ms));
	}

	static mytime_point now() {
		return myclock::now();
	}

	static int64_t timeDiffMs(const mytime_point& later, const mytime_point& before) {
		return std::chrono::duration_cast<ms_t>(later - before).count();
	}

	static int64_t timeDiffMs(const mytime_point& tp) {
		return timeDiffMs(now(), tp);
	}

	static int64_t whenMs(const mytime_point& tp) {
		return std::chrono::duration_cast<ms_t>(tp.time_since_epoch()).count();
	}
};

#endif // __MY_UTILS_H__